<!DOCTYPE html>

<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title></title>
        <script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.2.min.js"></script>
        <script type="text/javascript">
            $(document).ready(function () {
                $("#submitFile").click(function () {
                    var digest = $(window.parent.document).find('#formDigest').val();
                    var target = $(window.parent.document).find('#targetUrl').val();
                    var targetUrl = "upload_file.php?digest=" + digest + "&target=" + target;
                    targetUrl = encodeURI(targetUrl);
                    $("#uploaderForm").attr("action", targetUrl);
                    $("#uploaderForm").submit();
                });
            });
        </script>
    </head>
    <body>
        <form action="upload_file.php" id="uploaderForm" method="post" enctype="multipart/form-data" >
            <label for="file">Filename:</label>
            <input type="file" name="file" id="file" /> 
            <input type="button" name="upload" value="Submit" id="submitFile" />
        </form>        
    </body>
</html>
